using System.Collections.Generic;
using UnityEngine;

namespace Demo2048
{
    public class PanelManage : MonoBehaviour
    {
        public enum PanelType
        {
            Success,
            Failure,
            Main,
            Entry
        }

        private void Start()
        {
            panelDict = new Dictionary<PanelType, Transform>();
            panelDict[PanelType.Success] = success.transform;
            panelDict[PanelType.Failure] = failure.transform;
            panelDict[PanelType.Main] = main.transform;
            panelDict[PanelType.Entry] = entry.transform;

            foreach(Transform t in panelDict.Values)
            {
                t.transform.position = HIDDEN;
            }

            ActivatePanel(PanelType.Entry);
        }

        public void ChangePanel(PanelType type)
        {
            ActivatePanel(type);
        }

        void ActivatePanel(PanelType type)
        {
            panelDict[curType].position = HIDDEN;
            panelDict[type].position = DISPLAY;
            curType = type;
        }

        public void ChangePanel(string name)
        {
            if (name == "main")
            {
                ActivatePanel(PanelType.Main);
            }
        }

        public GameObject success;
        public GameObject failure;
        public GameObject main;
        public GameObject entry;

        private Dictionary<PanelType, Transform> panelDict;
        private PanelType curType;
        private readonly Vector3 HIDDEN = new Vector3(2000, 2000, 2000);
        private readonly Vector3 DISPLAY = Vector3.zero;
    }
}
